//
//  StonewtClass.cpp
//  Practice11
//
//  Created by 赵世杰 on 2020/7/26.
//  Copyright © 2020 zhaoshijie. All rights reserved.
//

#include "StonewtClass.hpp"
#include <iostream>

using namespace std;

Stonewt::Stonewt(double lbs)
{
    stone = int (lbs) / Lbs_per_stn;
    pds_left = int (lbs) % Lbs_per_stn + lbs - int(lbs);
    pounds = lbs;
    
}

Stonewt::Stonewt(int stn,double lbs)
{
    stone = stn;
    pds_left = lbs;
    pounds = stn * Lbs_per_stn + lbs;
    
}

Stonewt::Stonewt()
{
    stone = pounds = pds_left = 0;
}

Stonewt::~Stonewt()
{
    
}

void Stonewt::show_stn() const
{
    cout << stone << " stone," << pds_left << " pounds\n";
}

void Stonewt::show_lbs() const
{
    cout << pounds << " pounds\n";
}


Stonewt Stonewt::operator+(const Stonewt & ston) const
{
    Stonewt stonewt;
    stonewt.pounds = pounds + ston.pounds;
    stonewt.stone = stonewt.pounds / Lbs_per_stn;
    stonewt.pds_left = int (stonewt.pounds) % Lbs_per_stn + stonewt.pounds - int(stonewt.pounds);
    
    return stonewt;
    
}


Stonewt Stonewt::operator-(const Stonewt & ston) const
{
    Stonewt stonewt;
    stonewt.pounds = pounds - ston.pounds;
    stonewt.stone = stonewt.pounds / Lbs_per_stn;
    stonewt.pds_left = int (stonewt.pounds) % Lbs_per_stn + stonewt.pounds - int(stonewt.pounds);
    
    
    return stonewt;
    
}



Stonewt Stonewt::operator*(double n) const
{
    Stonewt stonewt;
    stonewt.pounds = pounds * n;
    stonewt.stone = stonewt.pounds / Lbs_per_stn;
    stonewt.pds_left = int (stonewt.pounds) % Lbs_per_stn + stonewt.pounds - int(stonewt.pounds);
    
    
    return stonewt;
}

Stonewt operator*(double n,const Stonewt &ston)
{
    return ston*n;
}


std::ostream & operator << (std::ostream & os , const Stonewt & t)
{
    
    os << "stone: " << t.stone << " pds_left: " << t.pds_left << " pounds: " << t.pounds << endl;
    
    return os;
}

bool Stonewt::operator>(const Stonewt &ston)const
{
    if(pounds>=ston.pounds)
    {
        return true;
    }
    
    return false;
}
